package cn.buk.tms.dto;

import cn.buk.tms.entity.misc.EntDepartment;
import cn.buk.tms.entity.misc.User;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yfdai on 15/12/13.
 */
public class UserDto {

    public static UserDto createByUser(User u) {
        UserDto dto = new UserDto();
        BeanUtils.copyProperties(u, dto, "departments");

        for(EntDepartment d: u.getDepartments()) {
            EntDepartmentDto dd = new EntDepartmentDto();
            BeanUtils.copyProperties(d, dd);
            dto.getDepartments().add(dd);
        }

        return dto;
    }

    public static UserDto createUserDto(int id, String vipName) {
        UserDto dto = new UserDto();
        dto.setId(id);
        dto.setVipName(vipName);

        return dto;
    }

    private int id;

    private int enterpriseId;

    private int parentEnterprise;

    private String enterpriseName;

    private String username="";

    /**
     * 状态
     * 1 - 正常
     * 4 - 停用
     */
    private int status;

    /**
     * 客户服务分组代码
     **/
    private String groupCode;
    /**
     * 客户服务分组名称
     */
    private String groupName;

    private String empname="";

    /**
     * 绑定的微信公众号的用户
     */
    private List<WeixinServiceUserDto> wxsUsers;

    /**
     * 企业微信的用户id
     */
    private String wwUserId;

    /**
     * 企业名称
     */
    private String corpName;

    /**
     * eterm 用户名
     */
    private String etermUsername;

    /**
     * 该账户是否启用
     */
    private String isopen="1";

    private String email="";

    private String mobileNo="";

    private int balance;

    /**
     * 现金账户的余额
     */
    private int cashBalance;

    private double cashBalanceYuan;

    private int frozenBalance;

    private double frozenBalanceYuan;

    /**
     * 信用额度
     */
    private int creditLimit;

    private double creditLimitYuan;

    private String audit;
    private String refundAudit;



    /**
     * 企业名称
     */
    private String vipName;

    /**
     * 企业名称
     */
    private String fullName;

    /**
     * 企业差旅负责人（审核人）
     */
    private String linkMan;

    /**
     * 联系电话
     */
    private String phone;

    private String fax;

    /**
     * 邮编
     */
    private String postCode;

    /**
     * 账单邮寄地址
     */
    private String address;


    /**
     * 备注
     */
    private String remark;

    /**
     * 是否需要审批出票
     * 0-不需要
     * 1-需要
     */
    private Integer approvalTicket;

    private List<EntDepartmentDto> departments;

    /**
     * 0 - 散客
     * 1 - 企业客户
     */
    private int userType;


    //以下为企业微信中独有的内容

    /**
     * 职位
     */
    private String position;

    /**
     * 性别
     * 0-未设置
     * 1-男
     * 2-女
     */
    private int gender;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 启用状态
     * 1-启用
     * 0-禁用
     */
    private int enable;

    /**
     * 别名
     */
    private String alias;

    /**
     * 对外展示的职位
     */
    private String externalPosition;

    private String telephone;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getEnterpriseId() {
        return enterpriseId;
    }

    public void setEnterpriseId(int enterpriseId) {
        this.enterpriseId = enterpriseId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmpname() {
        return empname;
    }

    public void setEmpname(String empname) {
        this.empname = empname;
    }

    public String getIsopen() {
        return isopen;
    }

    public void setIsopen(String isopen) {
        this.isopen = isopen;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobileNo() {
        return mobileNo;
    }

    public void setMobileNo(String mobileNo) {
        this.mobileNo = mobileNo;
    }

    public int getBalance() {
        return balance;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }

    public String getEnterpriseName() {
        return enterpriseName;
    }

    public void setEnterpriseName(String enterpriseName) {
        this.enterpriseName = enterpriseName;
    }

    public int getCashBalance() {
        return cashBalance;
    }

    public void setCashBalance(int cashBalance) {
        this.cashBalance = cashBalance;
        this.cashBalanceYuan = cashBalance / 100.0;
    }

    public double getCashBalanceYuan() {
        return cashBalanceYuan;
    }

    public int getFrozenBalance() {
        return frozenBalance;
    }

    public void setFrozenBalance(int frozenBalance) {
        this.frozenBalance = frozenBalance;
        this.frozenBalanceYuan = frozenBalance / 100.0;
    }

    public double getFrozenBalanceYuan() {
        return frozenBalanceYuan;
    }

    public void setCreditLimit(int creditLimit) {
        this.creditLimit = creditLimit;
        this.creditLimitYuan = creditLimit / 100.0;
    }

    public int getCreditLimit() {
        return creditLimit;
    }

    public double getCreditLimitYuan() {
        return creditLimitYuan;
    }

    public String getAudit() {
        return audit;
    }

    public void setAudit(String audit) {
        this.audit = audit;
    }

    public String getRefundAudit() {
        return refundAudit;
    }

    public void setRefundAudit(String refundAudit) {
        this.refundAudit = refundAudit;
    }

    public String getVipName() {
        return vipName;
    }

    public void setVipName(String vipName) {
        this.vipName = vipName;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getLinkMan() {
        return linkMan;
    }

    public void setLinkMan(String linkMan) {
        this.linkMan = linkMan;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getPostCode() {
        return postCode;
    }

    public void setPostCode(String postCode) {
        this.postCode = postCode;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getApprovalTicket() {
        return approvalTicket;
    }

    public void setApprovalTicket(Integer approvalTicket) {
        this.approvalTicket = approvalTicket;
    }

    public List<EntDepartmentDto> getDepartments() {
        if (departments == null) {
            departments = new ArrayList<>();
        }
        return departments;
    }

    public void setDepartments(List<EntDepartmentDto> departments) {
        this.departments = departments;
    }

    public String getWwUserId() {
        return wwUserId;
    }

    public void setWwUserId(String wwUserId) {
        this.wwUserId = wwUserId;
    }

    public String getEtermUsername() {
        return etermUsername;
    }

    public void setEtermUsername(String etermUsername) {
        this.etermUsername = etermUsername;
    }

    public int getParentEnterprise() {
        return parentEnterprise;
    }

    public void setParentEnterprise(int parentEnterprise) {
        this.parentEnterprise = parentEnterprise;
    }

    public int getUserType() {
        return userType;
    }

    public void setUserType(int userType) {
        this.userType = userType;
    }

    public String getCorpName() {
        return corpName;
    }

    public void setCorpName(String corpName) {
        this.corpName = corpName;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public int getEnable() {
        return enable;
    }

    public void setEnable(int enable) {
        this.enable = enable;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getExternalPosition() {
        return externalPosition;
    }

    public void setExternalPosition(String externalPosition) {
        this.externalPosition = externalPosition;
    }

    public String getGroupCode() {
        return groupCode;
    }

    public void setGroupCode(String groupCode) {
        this.groupCode = groupCode;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public List<WeixinServiceUserDto> getWxsUsers() {
        if (wxsUsers == null) {
            wxsUsers = new ArrayList<>();
        }
        return wxsUsers;
    }

    public void setWxsUsers(List<WeixinServiceUserDto> wxsUsers) {
        this.wxsUsers = wxsUsers;
    }
}
